using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using TimeTableManagement.Entities;

namespace TimeTableManagement.Mapping
{
	public class Tb_NewsMap : EntityTypeConfiguration<Tb_News>
	{
		public Tb_NewsMap()
		{
			// Primary Key
			this.HasKey(t => t.id);

			// Properties
			this.Property(t => t.title)
				.IsFixedLength()
				.HasMaxLength(255);
				
			this.Property(t => t.urlimage)
				.HasMaxLength(50);
				
			this.Property(t => t.option)
				.IsFixedLength()
				.HasMaxLength(255);
				
			// Table & Column Mappings
			this.ToTable("Tb_News");
			this.Property(t => t.id).HasColumnName("id");
			this.Property(t => t.title).HasColumnName("title");
			this.Property(t => t.startdate).HasColumnName("startdate");
			this.Property(t => t.enddate).HasColumnName("enddate");
			this.Property(t => t.id_user).HasColumnName("id_user");
			this.Property(t => t.content).HasColumnName("content");
			this.Property(t => t.urlimage).HasColumnName("urlimage");
			this.Property(t => t.status).HasColumnName("status");
			this.Property(t => t.type).HasColumnName("type");
			this.Property(t => t.option).HasColumnName("option");

			// Relationships
			this.HasRequired(t => t.Tb_Config)
				.WithMany(t => t.Tb_News)
				.HasForeignKey(d => d.type);
				
		}
	}
}

